/*
 *  Copyright 2011 Arngrimur Bjarnason 
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
 

/**
 * 
 */
package org.arngrimur.deviationtable.activity;

import org.arngrimur.deviationtable.R;
import org.arngrimur.deviationtable.R.string;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

/**
 * @author Arngrimur Bjarnason, arngrimurbjarnason@gmail.com
 * 
 */
public class DeleteCompass extends ListActivity {
	public static final int REQUEST_CODE = 0xF0;
	public static final String COMPASS_KEY = "compassToDelete";
	public static final String DELETE_INDEX = "deleteIndex";

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Intent deleteCompass = getIntent();
		String[] data = deleteCompass
				.getStringArrayExtra(getString(R.string.deletecompassvalues));
		setListAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, data));
		
	}
	
	@Override 
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		Intent result = new Intent();
		result.putExtra(DELETE_INDEX, position);
		setResult(Activity.RESULT_OK, result);
		finish();
	}
	
}
